package com.ebt.m.homepage;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.ebt.m.R;
import com.ebt.m.data.bean.Brand;
import com.ebt.m.wiki.ActSpecProductLibFilter;
import com.ebt.m.wiki.ActSpecProductLibSearch;
import com.ebt.m.wiki.view.ProductItemView1;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by andy.wang on 2016/12/8.
 */

public class HomeProposalContainer extends DynamicBaseView {

    @BindView(R.id.search_label)
    TextView searchLabel;
    @BindView(R.id.search_view)
    TextView searchView;
    private Brand brand;


    public HomeProposalContainer(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public HomeProposalContainer(Context context) {
        this(context, null);
    }

    public HomeProposalContainer(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        inflate(context, R.layout.layout_opportunity_mission, this);
        ButterKnife.bind(this);
    }


    @Override
    public void update(Object... args) {
        brand = (Brand) args[0];
        searchLabel.setText(brand.getBrandShortName());

    }


    @OnClick({R.id.search_label, R.id.search_view})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.search_label:
                Intent intent = new Intent(getContext(), ActSpecProductLibFilter.class);
                if (brand != null) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("currentBrand", brand);
                    intent.putExtras(bundle);
                }
                getContext().startActivity(intent);
                break;
            case R.id.search_view:
                Intent intent1 = new Intent(getContext(), ActSpecProductLibSearch.class);
                intent1.putExtra("Flag", ProductItemView1.FLAG_DYNAMIC);
                getContext().startActivity(intent1);
                break;
        }

    }
}
